package com.hzvictory.hotel_system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
//import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hzvictory.hotel_system.common.annotation.Log;
import com.hzvictory.hotel_system.common.core.controller.BaseController;
import com.hzvictory.hotel_system.common.core.domain.AjaxResult;
import com.hzvictory.hotel_system.common.enums.BusinessType;
import com.hzvictory.hotel_system.pojo.entity.Seatorder;
import com.hzvictory.hotel_system.service.ISeatorderService;
//mport com.hzvictory.hotel_system.common.utils.ExcelUtil;
import com.hzvictory.hotel_system.common.core.page.TableDataInfo;
/**
 * 功能
 * 作者：何征
 * 日期：2025/7/23 23:10
 */
@RestController
@RequestMapping("/system/seatorder")
public class SeatorderController extends BaseController
{
    @Autowired
    private ISeatorderService seatorderService;

    /**
     * 查询座位订单列表
     */
    //@PreAuthorize("@ss.hasPermi('system:seatorder:list')")
    @GetMapping("/list")
    public TableDataInfo list(Seatorder seatorder)
    {
        startPage();
        List<Seatorder> list = seatorderService.selectSeatorderList(seatorder);
        return getDataTable(list);
    }
    /**
     * 根据用户id查询座位订单列表
     */
    //@PreAuthorize("@ss.hasPermi('system:seatorder:list')")
    @GetMapping("/list/{userId}")
    public TableDataInfo list(@PathVariable("userId")Long userId)
    {
        startPage();
        List<Seatorder> list = seatorderService.selectSeatorderListByUserId(userId);
        return getDataTable(list);
    }

    /**
     * 导出座位订单列表
     */
    //@PreAuthorize("@ss.hasPermi('system:seatorder:export')")
//    @Log(title = "座位订单", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, Seatorder seatorder)
//    {
//        List<Seatorder> list = seatorderService.selectSeatorderList(seatorder);
//        ExcelUtil<Seatorder> util = new ExcelUtil<Seatorder>(Seatorder.class);
//        util.exportExcel(response, list, "座位订单数据");
//    }

    /**
     * 获取座位订单详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:seatorder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(seatorderService.selectSeatorderById(id));
    }

    /**
     * 新增座位订单
     */
    //@PreAuthorize("@ss.hasPermi('system:seatorder:add')")
    @Log(title = "座位订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Seatorder seatorder)
    {
        return toAjax(seatorderService.insertSeatorder(seatorder));
    }

    /**
     * 修改座位订单
     */
    //@PreAuthorize("@ss.hasPermi('system:seatorder:edit')")
    @Log(title = "座位订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Seatorder seatorder)
    {
        return toAjax(seatorderService.updateSeatorder(seatorder));
    }
    /**
     * 修改座位订单状态 1待支付->2已支付
     */

    @PutMapping("/status/{id}")
    public AjaxResult editStatusById(@PathVariable("id") Long id)
    {
        return toAjax(seatorderService.updateSeatorderStatusById(id));
    }

    /**
     * 删除座位订单
     */
    //@PreAuthorize("@ss.hasPermi('system:seatorder:remove')")
    @Log(title = "座位订单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(seatorderService.deleteSeatorderByIds(ids));
    }
}